package com.mall.db.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.db.mapper.PmsProductLadderMapper;
import com.mall.pojo.PmsProductLadder;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductLadderApiAmpl implements PmsProductLadderApi {
    @Autowired
    private PmsProductLadderMapper pmsProductLadderMapper;

    //创建商品(八接口之一)
    @Override
    public void create(List<PmsProductLadder> productLadderList) {
        if (productLadderList != null) {
            for (PmsProductLadder pmsProductLadder : productLadderList) {
                pmsProductLadderMapper.insert(pmsProductLadder);
            }
        }
    }

    //更新商品 更新八张表之一
    @Override
    public void update(List<PmsProductLadder> productLadderList) {
        if (productLadderList != null) {
            for (PmsProductLadder pmsProductLadder : productLadderList) {
                pmsProductLadderMapper.updateById(pmsProductLadder);
            }
        }
    }

    @Override
    public List<PmsProductLadder> selectById(Integer id) {
        LambdaQueryWrapper<PmsProductLadder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PmsProductLadder::getProductId, id);
        return pmsProductLadderMapper.selectList(wrapper);
    }
}
